In [1]:
import numpy as np
import xarray as xr

In [4]:
ds=xr.open_dataset('https://salishsea.eos.ubc.ca/erddap/griddap/ubcSSnBathymetry2V1')

In [5]:
ds


Out[5]:
<xarray.Dataset>
Dimensions:     (gridX: 398, gridY: 898)
Coordinates:
  * gridY       (gridY) int32 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 ...
  * gridX       (gridX) int16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 ...
Data variables:
    longitude   (gridY, gridX) float32 ...
    latitude    (gridY, gridX) float32 ...
    bathymetry  (gridY, gridX) float64 ...
Attributes:
    acknowledgement: MEOPAR, ONC, Compute Canada
    cdm_data_type: Grid
    comment: Bathymetry, Latitudes and Longitudes
    Conventions: CF-1.6, COARDS, ACDD-1.3
    coverage_content_type: modelResult
    creator_email: sallen@eos.ubc.ca
    creator_name: Salish Sea MEOPAR Project Contributors
    creator_url: https://salishsea-meopar-docs.readthedocs.org/
    drawLandMask: over
    history: [2016-02-05 16:35:19] Created dataset.
[2016-03-02 18:08:56] Changed all variables to zlib=True.
[2016-03-02 18:08:56] Added least_significant_digit=1 and fill_value=0 to bathymetry variable.
[2016-03-03 12:28:37] Added valid_range attribute to all variables.
2016-06-14T18:40:52Z (local files)
2016-06-14T18:40:52Z https://salishsea.eos.ubc.ca/erddap/griddap/ubcSSnBathymetry2V1.das
    infoUrl: https://salishsea-meopar-tools.readthedocs.org/en/latest/results_server/index.html#salish-sea-model-results
    institution: UBC EOAS
    institution_fullname: Earth, Ocean & Atmospheric Sciences, University of British Columbia
    keywords: bathymetry, bottom, data, model results, depth, floor, latitude, longitude, nemo, ocean, oceans,
Oceans > Bathymetry/Seafloor Topography > Bathymetry, salishsea, sea, sea_floor_depth, seafloor, topography
    keywords_vocabulary: GCMD Science Keywords
    license: The Salish Sea MEOPAR NEMO model results are copyright 2013-2016
by the Salish Sea MEOPAR Project Contributors and The University of British Columbia.

They are licensed under the Apache License, Version 2.0. http://www.apache.org/licenses/LICENSE-2.0
    project: Salish Sea MEOPAR NEMO Model
    references: https://bitbucket.org/salishsea/nemo-forcing/src/tipgrid/mesh_mask_SalishSea2.nc
    source: https://bitbucket.org/salishsea/tools/src/tip/bathymetry/NEMOBathymetryfromMeshMask.ipynb
    sourceUrl: (local files)
    standard_name_vocabulary: CF Standard Name Table v29
    summary: Salish Sea NEMO Model Grid, Geo-location and Bathymetry, v1

Longitude, latitude, and bathymetry of the Salish Sea NEMO model grid.
The bathymetry values are those calculated by NEMO from the input bathymetry file.
NEMO modifies the input bathymetry to remove isolated holes, and too-small partial steps.
The model grid includes the Juan de Fuca Strait, the Strait of Georgia, Puget Sound,
and Johnstone Strait on the coasts of Washington State and British Columbia.

v1: longitude, latitude and b...
    title: Salish Sea NEMO Model Grid, Geo-location and Bathymetry, v1

2 dimensions,2 coordinates, 3 variables


In [21]:
ds.data_vars


Out[21]:
Data variables:
    longitude   (gridY, gridX) float32 -123.429 -123.424 -123.419 -123.413 ...
    latitude    (gridY, gridX) float32 46.8597 46.8615 46.8634 46.8653 ...
    bathymetry  (gridY, gridX) float64 nan nan nan nan nan nan nan nan nan ...

In [6]:
ds.longitude


Out[6]:
<xarray.DataArray 'longitude' (gridY: 898, gridX: 398)>
[357404 values with dtype=float32]
Coordinates:
  * gridY    (gridY) int32 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ...
  * gridX    (gridX) int16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ...
Attributes:
    _ChunkSize: [898 398]
    colorBarMaximum: 180.0
    colorBarMinimum: -180.0
    long_name: Longitude
    standard_name: longitude
    units: degrees_east
    valid_range: [-126.40029144 -121.31835175]

In [7]:
ds.latitude


Out[7]:
<xarray.DataArray 'latitude' (gridY: 898, gridX: 398)>
[357404 values with dtype=float32]
Coordinates:
  * gridY    (gridY) int32 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ...
  * gridX    (gridX) int16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ...
Attributes:
    _ChunkSize: [898 398]
    colorBarMaximum: 90.0
    colorBarMinimum: -90.0
    long_name: Latitude
    standard_name: latitude
    units: degrees_north
    valid_range: [ 46.85966492  51.10480118]

In [8]:
ds.bathymetry


Out[8]:
<xarray.DataArray 'bathymetry' (gridY: 898, gridX: 398)>
[357404 values with dtype=float64]
Coordinates:
  * gridY    (gridY) int32 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ...
  * gridX    (gridX) int16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ...
Attributes:
    _ChunkSize: [898 398]
    colorBarMaximum: 450.0
    colorBarMinimum: 0.0
    colorBarPalette: OceanDepth
    grid: Salish Sea 2
    long_name: Depth of Bottom
    standard_name: sea_floor_depth
    units: m
    valid_range: [   0.  428.]

In [9]:
ds.latitude.shape


Out[9]:
(898, 398)

In [10]:
ds.longitude.shape


Out[10]:
(898, 398)

In [11]:
ds.bathymetry.shape


Out[11]:
(898, 398)

In [12]:
ds.latitude.values


Out[12]:
array([[ 46.85966492,  46.86154556,  46.86342621, ...,  47.59721375,
         47.59906769,  47.60092163],
       [ 46.86278915,  46.86481476,  46.86677933, ...,  47.60125732,
         47.60311127,  47.60496521],
       [ 46.86606979,  46.86814499,  46.87015915, ...,  47.60529709,
         47.60715485,  47.60900879],
       ..., 
       [ 50.38191605,  50.38397598,  50.38602448, ...,  51.09400177,
         51.09560776,  51.09720612],
       [ 50.38591766,  50.38798523,  50.39004135, ...,  51.09781265,
         51.0994072 ,  51.10100174],
       [ 50.38992691,  50.39200592,  50.39406967, ...,  51.10162354,
         51.10321808,  51.10480118]], dtype=float32)

In [13]:
ds.longitude.values


Out[13]:
array([[-123.42943573, -123.42411804, -123.41880035, ..., -121.32898712,
        -121.32366943, -121.31835175],
       [-123.43196869, -123.42677307, -123.42152405, ..., -121.33235931,
        -121.32704163, -121.32172394],
       [-123.43463898, -123.42948151, -123.42427063, ..., -121.33573151,
        -121.33041382, -121.32509613],
       ..., 
       [-126.39330292, -126.38764191, -126.3819809 , ..., -124.34471893,
        -124.340065  , -124.3354187 ],
       [-126.39678955, -126.39109802, -126.38541412, ..., -124.34797668,
        -124.34333801, -124.3387146 ],
       [-126.40029144, -126.39456177, -126.38883209, ..., -124.35121918,
        -124.34658813, -124.34198761]], dtype=float32)

In [15]:
ds.bathymetry.values


Out[15]:
array([[ nan,  nan,  nan, ...,  nan,  nan,  nan],
       [ nan,  nan,  nan, ...,  nan,  nan,  nan],
       [ nan,  nan,  nan, ...,  nan,  nan,  nan],
       ..., 
       [ nan,  nan,  nan, ...,  nan,  nan,  nan],
       [ nan,  nan,  nan, ...,  nan,  nan,  nan],
       [ nan,  nan,  nan, ...,  nan,  nan,  nan]])

In [17]:
ds.longitude>=-126


Out[17]:
<xarray.DataArray 'longitude' (gridY: 898, gridX: 398)>
array([[ True,  True,  True, ...,  True,  True,  True],
       [ True,  True,  True, ...,  True,  True,  True],
       [ True,  True,  True, ...,  True,  True,  True],
       ..., 
       [False, False, False, ...,  True,  True,  True],
       [False, False, False, ...,  True,  True,  True],
       [False, False, False, ...,  True,  True,  True]], dtype=bool)
Coordinates:
  * gridY    (gridY) int32 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ...
  * gridX    (gridX) int16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ...

In [18]:
ds.longitude.values[-126:-121]


Out[18]:
array([[-125.97533417, -125.97007751, -125.96482086, ..., -123.93197632,
        -123.9269104 , -123.92183685],
       [-125.97869873, -125.97344208, -125.96819305, ..., -123.93534851,
        -123.93027496, -123.92520905],
       [-125.98207092, -125.97681427, -125.97155762, ..., -123.93871307,
        -123.93364716, -123.92858124],
       [-125.98544312, -125.98017883, -125.97492218, ..., -123.94208527,
        -123.93701935, -123.9319458 ],
       [-125.98880768, -125.98355103, -125.97829437, ..., -123.94544983,
        -123.94038391, -123.93531799]], dtype=float32)

In [19]:
ds.longitude.values[46:48,-126:-121]


Out[19]:
array([[-122.13578796, -122.13048553, -122.12519073, -122.11989594,
        -122.11460114],
       [-122.13910675, -122.13381195, -122.12851715, -122.12321472,
        -122.11791992]], dtype=float32)

In [22]:
ds.latitude.values[-126:-121,46:48]


Out[22]:
array([[ 49.98813629,  49.99003983],
       [ 49.99204636,  49.99394989],
       [ 49.99595642,  49.99785995],
       [ 49.99986649,  50.00177383],
       [ 50.00378036,  50.0056839 ]], dtype=float32)

In [23]:
ds.longitude.values[-126:-121,46:48]


Out[23]:
array([[-125.73351288, -125.72825623],
       [-125.73683929, -125.73158264],
       [-125.74017334, -125.73491669],
       [-125.74350739, -125.73825073],
       [-125.74684143, -125.74157715]], dtype=float32)

In [ ]: